﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
namespace WPFExcelReport
{ 
    public partial class JLTRSAPS
    {
        #region ==IsShowGantt===========
        public static readonly DependencyProperty IsShowGanttProperty = DependencyProperty.Register("IsShowGantt",
            typeof(bool), typeof(JLTRSAPS),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowGanttChanged));
        public bool IsShowGantt
        {
            get
            {
                return (bool)GetValue(IsShowGanttProperty);
            }
            set
            {
                SetValue(IsShowGanttProperty, value);
                OnShowGanttChg(value);
            }
        }
        private static void OnIsShowGanttChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as JLTRSAPS;
            if (src != null)
            {
                src.IsShowGantt = (bool)e.NewValue; 
            }
        }
      
        #endregion
        VJLTRSAPS vm;
       
        public JLTRSAPS()
        {
            vm = new VJLTRSAPS();
            this.DataContext = vm;
            InitializeComponent();
            this.Name = "智能排产"; 
            cAV33.KSTKRS = "  ";
            cAV33.KST = "0210";
            cAV33.AMTYP = "RSGYG   ";
            cAV33.AGANG = "RS             ";
        }
        private void ReSetTab()
        {
            IsShowGantt = false;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        { 
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            IsLoaded = true; 
        } 

        private void OnShowGanttChg(bool show)
        {
            if (!show)
            {
                zAV33.SetValue(Grid.RowProperty, 1);
                return;
            }
            zAV37.SetValue(Grid.RowProperty, 1);
            zAV33.SetValue(Grid.RowProperty, 2);

            cAV37.MV.SetProd.Clear();
            cAV37.MV.SetProd.Merge(cAV33.MV.SetProd.Tables["ICC_MKRF"]);//将显示任务重置 
        } 
    }
}
